package com.example.houseman.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.houseman.entity.TCfTermination;
import com.example.houseman.service.ITCfTerminationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.org.dto.TerminationDto;
import com.org.vo.ResultEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 龚梦
 * @since 2021-03-30
 */
@RestController
@Slf4j
@RequestMapping("/hou/terminationController")
public class TCfTerminationController {


    @Autowired
    private ITCfTerminationService itCfTerminationService;

    @RequestMapping("selects")
    public ResultEntity selects(TerminationDto terminationDto){
        PageHelper.startPage(terminationDto.getPageNum(),terminationDto.getPageSize());
        QueryWrapper<TCfTermination> wrapper = new QueryWrapper<>();
        if(terminationDto.getCfTerminationNo()!=null){
            wrapper.like("cf_termination_no",terminationDto.getCfTerminationNo());
        }
        if(terminationDto.getInputUserName()!=null){
            wrapper.like("input_user_name",terminationDto.getInputUserName());
        }

        if(terminationDto.getPremiseName()!=null){
            wrapper.like("premise_name",terminationDto.getPremiseName());
        }
        if(terminationDto.getT1()!=null){
            wrapper.lt("input_date",terminationDto.getT1());
        }
        if(terminationDto.getT2()!=null){
            wrapper.ge("input_date",terminationDto.getT2());
        }
        List<TCfTermination> list = itCfTerminationService.list(wrapper);
        PageInfo<TCfTermination> info = new PageInfo<>(list);
        return ResultEntity.ok("200","查询成功",info);
    }


}
